

#ifndef MODEL_H
#define MODEL_H

#include <stdio.h>
#include <stdlib.h>

#include <map>
#include <vector>
#include <string>

#include <OpenGL/OpenGL.h>
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>

#include "Vec4.h"
#include "Aabb.h"

#include "Geometry.h"

#include "Texture.h"

using namespace std;


class Material
{
	
public:
	float Ka[4];
	float Kd[4];
	float Ks[4];
	float Ns;		// shininess

	Material()
	{ 
		for (int i=0;i<4;i++)
			Ka[i] = Kd[i] = Ks[i] = 1;
		Ns = 0;
	}
};




class Model  
{

public:

	Model(const char* obj_file);
	
	virtual ~Model();
	

	int		matTotal;	       // total material 
	map<string, int> matMap;   // matMap[material_name] = material_ID
	Material	mat[100];	   // material ID	

	
	Geometry m_geometry;
	

	// AABB of triangles in model
	Aabb m_aabb;
	
	
	void loadDiffuseTexture(std::string filename);
	void loadPaintedTexture(std::string filename);
	
	
	// Texture for rendering original geometry
	Texture* m_diffuseTexture;
	
	// Texture containing user-painted per-vertex weights for fracture seeding
	Texture* m_paintedTexture;
	
			
	void debugRender();
	
	
private:
		
	// Loads a .obj model from disk
	bool LoadObj(string obj_file);
	
	// Loads a .mtl material file from disk (.mtl should be included in directory along with .obj)
	bool LoadObjMaterial(string mat_file);
		
	FILE	*fp_scene, *fp_material;
	string  s_file, t_file;
	char	mat_file[50];	   // material file name
	
	
};

#endif //MODEL_H
